package zzjson.rabbitmq.dlx;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import zzjson.rabbitmq.BaseRabbitMq;

/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2019 shuncom team All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description :消息生产者，通过TTL测试死信队列</li>
 * <li>Version     : 1.0.0</li>
 * <li>Creation    : 2019年04月25日</li>
 * <li>@author     : zzy0_0</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
public class DLXProvider {
	public static void main(String[] args) throws Exception {
		Connection conn = BaseRabbitMq.getConn();
		Channel channel = conn.createChannel();

		String msg = "测试死信队列";

		// 设置属性，消息10秒钟过期
		AMQP.BasicProperties properties = new AMQP.BasicProperties.Builder()
				.deliveryMode(2) // 持久化消息
				.contentEncoding("UTF-8")
				.expiration("10000") // TTL
				.build();

		channel.basicPublish("", "TEST_DLX_QUEUE", properties, msg.getBytes());

		BaseRabbitMq.close(channel, conn);
	}
}